<template>
    <div class="page_404">
        <headerBar :title="title"></headerBar>
        <img src="../assets/images/404.png" class="img_404">
        <div class="tip_404">{{time}} 秒后跳转到首页</div>
    </div>
</template>


<script>
import headerBar from "@/components/headerBar";
export default {
  components: {
    headerBar
  },
  data() {
    return {
      time: 5,
      id: "",
      title: 'oops！你发现一个不存在的页面'
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.id = setInterval(() => {
        this.time--;
        if (this.time === 0) {
          clearInterval(this.id);
          this.$router.push("/");
        }
      }, 1000);
    });
  },
  beforeDestroy() {
    if (this.id) clearInterval(this.id);
  }
};
</script>


<style lang="scss">
.page_404 {
  height: 100%;
  width: 100%;
  min-height: 100vh;
  position: relative;
  background-color: #fff;
}
.img_404 {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #fff;
  height: 300px;
  width: 300px;
}
.tip_404 {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  font-weight: 600;
}
</style>
